//
// Created by root on 17-11-1.
//

#ifndef MPP_LINUX_C_CODEC_H
#define MPP_LINUX_C_CODEC_H

#include <iostream>
#include "../rkrga/RGA.h"

extern "C" {
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>

//#include "rockchip/vpu.h"
#include "rockchip/rk_mpi.h"
#include "rockchip/rk_type.h"
#include "rockchip/vpu_api.h"
#include "rockchip/mpp_err.h"
#include "rockchip/mpp_task.h"
#include "rockchip/mpp_meta.h"
#include "rockchip/mpp_frame.h"
#include "rockchip/mpp_buffer.h"
#include "rockchip/mpp_packet.h"
#include "rockchip/rk_mpi_cmd.h"

#include "../rkdrm/bo.h"
#include "../rkdrm/dev.h"
#include "../rkdrm/modeset.h"
};

class Codec {
public:
    Codec();
    ~Codec();
    int init(const char *file_input,
             const char *file_output, MppCodingType type,
             int src_w, int src_h, int display);
    int deinit();
    int decode_one_pkt(MppPacket pkt);
    int decode();
    int dump_mpp_frame_to_file(MppFrame frame, FILE *fp);
    int drm_show_frame(MppFrame frame);

private:
    int mEos;
    int mDisPlay;
    int mFrmCnt;

    int srcW;
    int srcH;
    int dstW;
    int dstH;

    FILE *mFin;
    FILE *mFout;

    MppCtx mCtx;
    MppApi *mApi;
    //MppBuffer mBuffer { NULL };
    MppBufferGroup mFrmGrp { NULL };

    RGA *mRGA;

    sp_dev *mDev;
    sp_plane **mPlanes;
    sp_crtc *mCrtc;
    sp_plane *mTestPlane;
};


#endif //MPP_LINUX_C_CODEC_H
